#ifndef FRAMELESSWIDGET_H
#define FRAMELESSWIDGET_H

#include <QWidget>

// 针对9个区域，定义枚举的类型
enum Location {
    TOP,
    BOTTOM,
    LEFT,
    RIGHT,
    TOP_LEFT,
    TOP_RIGHT,
    BOTTOM_LEFT,
    BOTTOM_RIGHT,
    CENTER
};

class FramelessWidget : public QWidget
{
    Q_OBJECT

private:
    // 是否是左键按下
    bool isLeftPressed;

    // 点击距离和窗口左上角的位置
    QPoint mouseOffset;

    // 位置区域
    Location location;

protected:
    // 鼠标按下
    void mousePressEvent(QMouseEvent* event) override;

    // 鼠标移动
    void mouseMoveEvent(QMouseEvent* event) override;

    // 鼠标释放
    void mouseReleaseEvent(QMouseEvent* event) override;

    void setCursorShape(const QPoint& point);

public:
    FramelessWidget(QWidget *parent = nullptr);
    ~FramelessWidget();
};
#endif // FRAMELESSWIDGET_H
